console.log('1111')
const express = require('express')
const axios = require('axios')

const app = express()
app.use(express.urlencoded({ extended: false })) // 现在就方便多了，express的两个方法一执行就行啦
app.use(express.json())
app.get('/example', async (req, res) => {
  try {
    const response = await axios.get('http://api.example.com/data')
    // 处理响应数据
    res.json(response.data)
  } catch (error) {
    // 处理错误
    console.error('Error fetching data:', error)
    res.status(500).json({ error: 'Error fetching data' })
  }
})

app.listen(3000, () => {
  console.log('Server is running on port 3000')
})
